package dice.sinanya.system;

import kotlin.jvm.functions.Function1;
import net.mamoe.mirai.utils.Context;
import net.mamoe.mirai.utils.DeviceInfo;
import net.mamoe.mirai.utils.SystemDeviceInfo;
import org.jetbrains.annotations.NotNull;

import static dice.sinanya.start.MiraiConfig.getEntityDevice;
import static dice.sinanya.start.MiraiConfig.getEntityDeviceString;
import static dice.sinanya.system.MessagesSystem.entityDevice;

public class Device extends SystemDeviceInfo implements Function1<Context, DeviceInfo> {

    @NotNull
    @Override
    public byte[] getFingerprint() {
        entityDevice.put("fingerprint", getEntityDevice("fingerprint", super.getFingerprint()));
        return getEntityDevice("fingerprint");
    }

    @NotNull
    @Override
    public byte[] getBootId() {
        entityDevice.put("bootId", getEntityDevice("bootId", super.getBootId()));
        return getEntityDevice("bootId");
    }

    @NotNull
    @Override
    public byte[] getProcVersion() {
        entityDevice.put("procVersion", getEntityDevice("procVersion", super.getProcVersion()));
        return getEntityDevice("procVersion");
    }

    @NotNull
    @Override
    public byte[] getImsiMd5() {
        entityDevice.put("imsiMd5", getEntityDevice("imsiMd5", super.getImsiMd5()));
        return getEntityDevice("imsiMd5");
    }

    @NotNull
    @Override
    public String getImei() {
        entityDevice.put("imei", getEntityDeviceString("imei", super.getImei()));
        return getEntityDeviceString("imei");
    }

    @Override
    public DeviceInfo invoke(Context context) {
        return this;
    }
}
